package com.ai.bitcoin.jpa.service.impl;

import com.ai.bitcoin.jpa.dao.BccDailyInfoDao;
import com.ai.bitcoin.jpa.entity.BccDailyInfo;
import com.ai.bitcoin.jpa.service.BccDailyInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Jason
 * @date 2018/4/4
 **/
@Component
@Slf4j
public class BccDailyInfoServiceImpl implements BccDailyInfoService {
    @Autowired
    BccDailyInfoDao dao;

    @Override
    public List<BccDailyInfo> findByBccIdAndBatchNo(String bccId, String batchNo) {
        return dao.findByBccIdAndBatchNo(bccId, batchNo);
    }

    @Override
    public List<BccDailyInfo> findByBccIdAndRecordState(String bccId, String recordState) {
        return dao.findByBccIdAndRecordState(bccId, recordState);
    }

    @Override
    @Transactional
    public void update2Publish(String latestBatch) {
        dao.deleteOldPublish(latestBatch);
        dao.update2Publish(latestBatch);
    }

    @Override
    @Transactional
    public void deleteNoPublish() {
        dao.deleteNoPublish();
    }

    @Override
    public List<BccDailyInfo> findByBccId(String bccId) {
        return dao.findByBccId(bccId);
    }

    @Override
    @Transactional
    public void save(BccDailyInfo bccDailyInfo) {
        dao.save(bccDailyInfo);
    }

    @Override
    public List<BccDailyInfo> findByRecordState(String recordState) {
        return dao.findByRecordState(recordState);
    }
}
